Repository navigation
Fix leaks, round-trip failures and config bugs from the second bug hunt - #90
Merged
Merged
Conversation
…g hunt Masking: - Masks of military IDs, BR numbers, passports, tax numbers and units are regenerated until they differ from the original and from the open text (a military ID was masked as itself about once in a hundred). - Components of open numbers (1.2, 2024-2025) count as open text, so a numeric mask cannot match part of them. - Names in brackets, slashes or asterisks are recognised; the closing bracket is no longer swallowed by the patronymic mask. - Infinitives (Видати, Надати) are not taken for surnames. - Ranks after * or / are found with all their words. - Custom-pattern and always_mask masks are held as placeholders until the name pass is over, so they are not masked twice; protected phrases are skipped by custom patterns. - Text dates keep the month's case and do not start inside a longer number. Unmasking: - JSON strings are unmasked as one text, matching how masking numbers mask occurrences across the document; masking also treats them as one text. - Text-date months are restored in the case found in the masked text. Configuration: - exclusions match all apostrophe variants; the local template no longer erases shared lists; max_name_length is null in the shared config. - ENV booleans with unknown words are skipped with a warning; ENV preserve_case wins over the file; router_rules filters combine with enable_*; password_generation strings, fractional integers, re-mask warn counts and empty sections are handled. - hash_algorithm case, backup_suffix separators, non-string logging.level and non-string section keys give errors instead of tracebacks. - diagnose returns 1 for unreadable or malformed mapping files. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XT6iUWaQgahXDB9TWX9Bq7 Generated-With: Claude Code 2.1.42
- system.encoding: auto honours a BOM (UTF-8/16/32) and keeps it byte for byte; text that decodes only with NUL characters is an error, not cp1251 (a UTF-16 file was left unmasked with exit 0). - --only/--exclude also drive the numbers of other documents, like enable_orders. - The mapping records input_format; unmask uses it instead of the masked file's extension (older mappings still use the extension). JSON input with a UTF-8 BOM is accepted. - unmask applies the same size limit as mask. - --password with security.encrypt_output: true is accepted; a password that is not valid UTF-8 is rejected before any file is written. - -o pointing to a hard link of the input is refused. - Mappings with an empty mask are rejected. - The report shows the executed number of --re-mask passes. - Damaged format-2 .enc headers and --init-config into a missing folder give errors instead of tracebacks. - unmask returns 2 for wrong usage (unset --password-env variable, missing --map, --to-version out of range or on a non-chain mapping). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XT6iUWaQgahXDB9TWX9Bq7 Generated-With: Claude Code 2.1.42
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Second bug hunt. It used new fuzzers (numeric entities, JSON, brackets and slashes, verb-led lines,
--re-maskchains) plus audits of the configuration layer and of the command-line and I/O layer. All entries are inCHANGELOG.mdunder[Unreleased].Masking leaks
№5дскin 10. These masks are now regenerated until they differ from the original and from the open text. Masks that already differed are unchanged.(Петренко Іван Петрович)kept the surname open and lost the closing bracket.Видати Петренку Івану: the infinitive was masked as a surname.always_maskand custom-pattern masks were masked a second time as surnames, so unmasking returned a mask instead of the original. A custom pattern could also match a protected phrase's placeholder, and the phrase disappeared.system.encoding: autoread UTF-16 as cp1251: nothing was masked, and the run still exited with 0. A BOM now decides the encoding, and round trips keep the file byte for byte.Unmasking did not restore the original
datamasking/_jsontext.py).п. 1.2).*старший матрос …*: the rank was masked without its first word.123 травня 2025was masked starting from23.input_format), not from the masked file's extension.Configuration
exclusionsmatch all apostrophe variants.max_name_lengthisnullin the shared config.DATA_MASKING_ENCRYPT_OUTPUT=yproduced a plaintext mapping.preserve_casenow wins over the file.router_rulesfilters combine withenable_*.password_generation: "false", fractional integers,--re-maskwarn counts, empty sections.hash_algorithmcase,backup_suffixseparators, non-stringlogging.level, non-string section keys.diagnosereturns 1 for bad files.Command line and files
--only/--excludealso control other document numbers.unmaskapplies the same size limit asmask.--passwordworks together withencrypt_output: true.-opointing to a hard link of the input is refused..encv2 headers,--init-configinto a missing folder.unmaskexits with 2 for wrong usage. Two assertions intests/test_to_version.pychange from 1 to 2.Tests
New test files. The share failing on
mainis shown for each:maintests/test_fuzz_findings2.pytests/test_config_findings.pytests/test_cli_findings.py--re-maskchains.🤖 Generated with Claude Code
https://claude.ai/code/session_01XT6iUWaQgahXDB9TWX9Bq7